home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wwais103 / view.frm < prev    next >
Text File  |  1995-05-08  |  9KB  |  304 lines

  1. VERSION 2.00
  2. Begin Form view_form 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "View"
  5.    ClientHeight    =   6915
  6.    ClientLeft      =   210
  7.    ClientTop       =   345
  8.    ClientWidth     =   9360
  9.    DrawMode        =   6  'Invert
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Terminal"
  13.    FontSize        =   9
  14.    FontStrikethru  =   0   'False
  15.    FontUnderline   =   0   'False
  16.    Height          =   7320
  17.    Left            =   150
  18.    LinkMode        =   1  'Source
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   6915
  21.    ScaleWidth      =   9360
  22.    Top             =   0
  23.    Width           =   9480
  24.    Begin Frame Frame1 
  25.       BackColor       =   &H0080FF80&
  26.       Height          =   855
  27.       Left            =   0
  28.       TabIndex        =   3
  29.       Top             =   6120
  30.       Width           =   9615
  31.       Begin CommandButton view_done 
  32.          Caption         =   "&Done"
  33.          Height          =   375
  34.          Left            =   2760
  35.          TabIndex        =   2
  36.          Top             =   240
  37.          Width           =   1095
  38.       End
  39.       Begin CommandButton view_save 
  40.          Caption         =   "&Save"
  41.          Height          =   375
  42.          Left            =   1560
  43.          TabIndex        =   1
  44.          Top             =   240
  45.          Width           =   1095
  46.       End
  47.       Begin CommandButton view_addsec 
  48.          Caption         =   "&Add Section"
  49.          Height          =   375
  50.          Left            =   240
  51.          TabIndex        =   0
  52.          Top             =   240
  53.          Width           =   1215
  54.       End
  55.    End
  56.    Begin TextBox Text1 
  57.       BackColor       =   &H00FFFFFF&
  58.       Height          =   6135
  59.       Left            =   0
  60.       MultiLine       =   -1  'True
  61.       ScrollBars      =   3  'Both
  62.       TabIndex        =   4
  63.       Text            =   "Text1"
  64.       Top             =   0
  65.       Width           =   9375
  66.    End
  67. End
  68. Dim rec As String * 80
  69.  
  70. Dim word(19) As String
  71. Dim recno As Integer
  72. Dim doc_lines As Integer
  73. Dim lines_per_page As Integer
  74. Dim line_size As Single
  75.  
  76. Dim box_top As Single
  77. Dim box_bottom As Single
  78.  
  79. Dim box_drawn As Integer
  80.  
  81. Dim button_down As Integer
  82.  
  83.  
  84. Sub CheckNewLines (LineFrom As String, FileNum As Integer)
  85. Do Until EOF(FileNum)
  86.     char$ = Input$(1, FileNum)
  87.     If char$ <> Chr$(13) Then
  88.         If char$ <> Chr$(10) Then
  89.             LineFrom$ = LineFrom$ + char$
  90.         Else
  91.             GotFeed% = True
  92.             If EOF(FileNum) Then
  93.                 Exit Do
  94.              End If
  95.             EndLine$ = Input$(1, FileNum)
  96.             If EndLine$ = Chr$(10) Or EndLine$ = Chr$(13) Then
  97.                EndLine$ = Chr$(13) + Chr$(10)
  98.                LineFrom$ = LineFrom$ + EndLine$
  99.             ElseIf EndLine$ <> Chr$(13) Then
  100.                 EndLine$ = Chr$(13) + Chr$(10) + EndLine$
  101.                 LineFrom$ = LineFrom$ + EndLine$
  102.             End If
  103.         End If
  104.     Else
  105.         GotReturn% = True
  106.         If EOF(FileNum) Then
  107.             Exit Do
  108.             End If
  109.         char$ = Input$(1, FileNum)
  110.         If char$ = Chr$(10) Then
  111.             GotCR_LF% = True
  112.             EndLine$ = Chr$(13) + Chr$(10)
  113.         ElseIf char$ = Chr$(13) Then
  114.             EndLine$ = Chr$(13) + Chr$(10)
  115.  
  116.  
  117.         Else
  118.             EndLine$ = Chr$(13) + Chr$(10) + char$
  119.         End If
  120.  
  121.         LineFrom$ = LineFrom$ + EndLine$
  122.         If GotCR_LF% = True Then
  123.             Exit Do
  124.         End If
  125.     End If
  126.     Loop
  127.  
  128. End Sub
  129.  
  130. Sub Form_Load ()
  131.      
  132.     Open "wais.$$$" For Input As 1
  133.     If LOF(1) > 60000 Then
  134.         text1.Text = "File too Large for Display - Press Save to Save it"
  135.     Else
  136.     CheckNewLines Lines$, 1
  137.     Do Until EOF(1)
  138.             Line Input #1, NextLine$
  139.             Lines$ = Lines$ + NextLine$ + Chr$(13) + Chr$(10)
  140.     Loop
  141.     text1.Text = Lines$
  142.     End If
  143.      Close (1)
  144.     z = DoEvents()
  145.     
  146. End Sub
  147.                    
  148.  
  149. Sub show_page ()
  150.     
  151.     Dim wdno As Integer
  152.     Static init_find As Integer
  153.     Static pos As Integer
  154.  
  155.     If Not init_find Then
  156.         GoSub first_find
  157.     End If
  158.  
  159.     view_form.Cls
  160.     ln = -1
  161.  
  162.     For X = recno To recno + lines_per_page
  163.         
  164.         If X < doc_lines Then
  165.             
  166.             Get #1, X, rec
  167.             view_form.Print " "; rec
  168.             ln = ln + 1
  169.         
  170.             If question_form.keywords.Text <> "" Then
  171.                 rec = LCase$(rec)
  172.  
  173.                 For Y = 0 To wdno
  174.                     pos = 1
  175.                     While pos > 0
  176.                         pos = InStr(pos, rec, word(Y))
  177.                         If pos > 0 Then
  178.                         
  179.                             view_form.drawmode = 7
  180.                             wd_left = pos * view_form.TextWidth("A")
  181.                             wd_right = (pos + Len(word(Y))) * view_form.TextWidth("A")
  182.                             wd_top = ln * view_form.TextHeight("A")
  183.                             wd_bottom = wd_top + view_form.TextHeight("A")
  184.                             view_form.Line (wd_left, wd_top)-(wd_right, wd_bottom), &HFFFF&, BF
  185.                             view_form.drawmode = 6
  186.                             currentx = 0
  187.                             pos = pos + Len(word(Y))
  188.                         End If
  189.                     Wend
  190.                 Next Y
  191.             End If
  192.         End If
  193.  
  194.     Next X
  195.  
  196. Exit Sub
  197.  
  198. first_find:
  199.  
  200.     words$ = LCase$(question_form.keywords.Text)
  201.     
  202.     c1 = 1
  203.     For wdno = 0 To 19
  204.         c2 = InStr(c1, words$, " ")
  205.         If c2 = 0 Then
  206.             word(wdno) = Left$(words$, Len(words$) - c1 + 1)
  207.             Exit For
  208.         End If
  209.         word(wdno) = Mid$(words$, c1, c2 - c1)
  210.         c1 = c2 + 1
  211.     
  212.         If word(wdno) = "and" Or word(wdno) = "" Or word(wdno) = Space$(Len(word(wdno))) Then
  213.             wdno = wdno - 1
  214.         End If
  215.  
  216.     Next wdno
  217.   
  218.     init_find = True
  219.  
  220. Return
  221.     
  222. End Sub
  223.  
  224. Sub view_addsec_Click ()
  225. lwidth% = text1.width / TextWidth("a")
  226.  
  227.     If text1.SelLength < 1 Then
  228.         MsgBox ("You haven't selected a section to add")
  229.         Exit Sub
  230.     End If
  231.  
  232.     ref = question_form.reference.listcount
  233.     title = question_form.title.listindex
  234.      l1% = text1.SelStart / lwidth%
  235.     ref_start(ref) = l1%
  236.     l2% = (text1.SelStart + text1.SelLength) / lwidth%
  237.     ref_end(ref) = l2%
  238.     ref_doc_size(ref) = title_doc_size(title)
  239.     ref_type(ref) = title_type(title)
  240.     ref_doc_bytes(ref) = title_doc_bytes(title)
  241.     
  242.     ref_title$ = question_form.title.Text
  243.     ref_line$ = "[" + LTrim$(Str$(ref_start(ref))) + "," + LTrim$(Str$(ref_end(ref))) + "]" + Right$(ref_title$, Len(ref_title$) - 11)
  244.     
  245.     question_form.reference.AddItem ref_line$
  246.     
  247. End Sub
  248.  
  249. Sub view_done_Click ()
  250.  
  251.     Unload view_form
  252.  
  253. End Sub
  254.  
  255. Sub view_save_Click ()
  256.       Dim rec As String * 500
  257.       If InStr(title_type(title), "TEXT") Then
  258.         save_form.Show 1
  259.       ElseIf InStr(title_type(title), "WSRC") Then
  260.  
  261.             new_src_form.s_add_server.Text = ""
  262.             new_src_form.s_add_port.Text = ""
  263.             new_src_form.s_add_database.Text = ""
  264.             Close (1)
  265.             Open "wais.$$$" For Input As 1
  266.             Do Until EOF(1)
  267.                 
  268.                 Line Input #1, rec
  269.                 last = 1
  270.                 If InStr(last, LCase$(Left$(rec, Len(rec))), ":ip-name") Then
  271.                     c1 = InStr(rec, Chr$(34))
  272.                     c2 = InStr(c1 + 1, rec, Chr$(34))
  273.                     last = c2 + 1
  274.                     new_src_form.s_add_server.Text = Mid$(rec, c1 + 1, c2 - c1 - 1)
  275.                 End If
  276.                 If InStr(last, LCase$(Left$(rec, Len(rec))), ":tcp-port") > 1 Then
  277.                      i = InStr(last, LCase$(Left$(rec, Len(rec))), ":tcp-port") + 9
  278.                     port$ = Str$(Val(Mid$(rec, i, Len(rec) - 10)))
  279.                     new_src_form.s_add_port.Text = Right$(port$, Len(port$) - 1)
  280.                     last = i
  281.                 End If
  282.                 If InStr(last, LCas